<?php
class siteRoot{
	
	private $wRoot;
	private $sRoot;
	private $dotPath;
	
//	public function wRoot(){
//		$exp=explode("/",$_SERVER['PHP_SELF'],4);
//		if($_SERVER['HTTP_HOST'] != 'localhost')
//		{
//		   $exp[1] = "";
//		}
//		
//		$wRoot = "http://" . $_SERVER['SERVER_NAME']."/".$exp[1].'/';
//		
//		return $wRoot;
//	}
	public function wRoot(){
		$exps=explode("/",$_SERVER['PHP_SELF'],4);
		if($_SERVER['HTTP_HOST'] != 'localhost')
		{
		   $ex = "";
		}else{
			$ex = '';
			foreach($exps as $exp){
				if (!empty($exp) && stristr(strtolower ($exp), '.php') === FALSE){
					$ex .= $exp .'/';
				}
			}
		}
		$wRoot = "http://" . $_SERVER['SERVER_NAME']."/".$ex;
		
		return $wRoot;
	}
	public function dotPath(){
		$exp = explode("/",$_SERVER['PHP_SELF']);
		print_r($exp);
		$count = sizeof($exp);
		$d = '';
		for($i=3; $i<$count; $i++){
			$d .= '../';
		}
		$dotPath = $d;
		return $dotPath;
	}
	public function pathname(){
		return dirname(__FILE__); 
	}
	
	public function basepath(){
		return basename(dirname(__FILE__)); 
	}
}
$path = new siteRoot();
//echo "<pre>";
//print_r($_SERVER);
//echo "</pre>";
define('PATH_NAME', $path->pathname());
define('WROOT', $path->wRoot());
?>